$(function () {
    $('#page').load('page.html');
})


function deleteById(id) {
    let data=myAjax("/user/delete",{id:id},"post");
    data=data.result;
    if (data==1){
        alert("删除成功！");
        $('#middle-reght').load('user/user.html');
    }else {
        alert("删除失败！");
    }
}

function FindAll() {
    let da={
        code:$.trim($("#code").val()),
        typeName:$("#user-Type").val(),
        name:$.trim($("#name").val()),
        sex:$("#sex").val(),
        education:$.trim($("#education").val()),
        groupCode:$("#groupCode").val(),
        pageSize:$("#pageSize").val(),
        pageNum:$("#pageNum").val(),
    }
    let data=myAjax("/user/findCondition",da,"post");
    $("#pageCount").text(data.number);
    data=data.list;
    let html='';
    for (let i=0;i<data.length;i++){
        html+='        <tr>\n' +
            '            <td>'+data[i].id+'</td>\n' +
            '            <td>'+data[i].code+'</td>\n' +
            '            <td>'+data[i].typeName+'</td>\n' +
            '            <td>'+data[i].name+'</td>\n' +
            '            <td>'+data[i].sex+'</td>\n' +
            '            <td>'+data[i].age+'</td>\n' +
            '            <td>'+data[i].education+'</td>\n' +
            '            <td>'+data[i].university+'</td>\n' +
            '            <td><div class="biaos">'+data[i].naative+'</div></td>\n' +
            '            <td><div class="biaos">'+data[i].address+'</div></td>\n' +
            '            <td>'+data[i].phone+'</td>\n' +
            '            <td>'+data[i].otherphone+'</td>\n' +
            '            <td>'+data[i].groupCode+'</td>\n' +
            '            <td><input type="button" value="编辑" onclick="updataById('+data[i].id+',\''+data[i].typeName+'\')"><input type="button" value="删除" onclick="deleteById('+data[i].id+')"></td>\n' +
            '        </tr>';
    }
    $("#userFandAll").html(html);
}

function updataById(id,name){
    localStorage.setItem("updataById",id);
    localStorage.setItem("name",name);
    $('#middle-reght').load('../html/user/userUpdata.html');
}


function FindAlls() {
    let data=myAjax("/user/findAll","","get");
    data=data.list;
    let html='';
    for (let i=0;i<data.length;i++){
        html+='        <tr>\n' +
            '            <td>'+data[i].id+'</td>\n' +
            '            <td>'+data[i].code+'</td>\n' +
            '            <td>'+data[i].typeName+'</td>\n' +
            '            <td>'+data[i].name+'</td>\n' +
            '            <td>'+data[i].sex+'</td>\n' +
            '            <td>'+data[i].age+'</td>\n' +
            '            <td>'+data[i].education+'</td>\n' +
            '            <td>'+data[i].university+'</td>\n' +
            '            <td><div class="biaos">'+data[i].naative+'</div></td>\n' +
            '            <td><div class="biaos">'+data[i].address+'</div></td>\n' +
            '            <td>'+data[i].phone+'</td>\n' +
            '            <td>'+data[i].otherphone+'</td>\n' +
            '            <td>'+data[i].groupCode+'</td>\n' +
            '            <td><input type="button" value="编辑" onclick="updataById('+data[i].id+')"><input type="button" value="删除" onclick="deleteById('+data[i].id+')"></td>\n' +
            '        </tr>';
    }
    $("#userFandAll").html(html);
}